package br.unesp.demac.ccn2007.aula5.naval;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import java.awt.event.*;

@SuppressWarnings("serial")
public class JanelaGrid extends JFrame implements ActionListener{
	
	public class SeaButton extends JButton {
		
		String location;
		
		public SeaButton(String string) {
			location = string;
		}

		
	}
	
	public JanelaGrid() {
        setTitle("Batalha Naval");
        setSize(200, 200);
        Container cp = getContentPane(); // container
        cp.setLayout(new GridLayout(10, 10)); // layout GridLayout
        for (int i=0; i<10; i++) {
        	for (int j=0; j<10; j++) {
        		SeaButton b = new SeaButton(j + "," + i);
	            b.setSize(20, 20);
	            cp.add(b);
	            b.addActionListener(this);
        	}
	            
        }
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(300, 300);
		setVisible(true);
    }
	
	@Override
	public void actionPerformed(ActionEvent evento){
		if(evento.getSource() == botao)
			botao.setText("Fui clicado");
		else
			botao2.setText("Fui clicado tb");
	}
}